#ifndef _EVENT_MANAGER_HPP
#define _EVENT_MANAGER_HPP

#include "Function.hpp"
#include "Args.hpp"
#include <vector>
#include <map>

#ifndef _CMP_STR
#define _CMP_STR
struct cmp_str
{
	bool operator()(const char *a, const char *b)
	{
		return std::strcmp(a, b) < 0;
	}
};
#endif

namespace lua
{

class EventManager
{
public:
	static EventManager* getInstance();
	static EventManager *instance;
	friend class Event;
	friend class ModuleManager;
private:
	EventManager();
	~EventManager();
	void add(Event *event);
	bool remove(const char *eventName, Function callbackFunc);
	bool trigger(const char *eventName, Args args);
private:
	std::map<const char*, std::vector<Event*>, cmp_str> mEvents;
};

}

#endif